/*
 * Powered By [rapid-framework]
 * Web Site: http://www.rapid-framework.org.cn
 * Google Code: http://code.google.com/p/rapid-framework/
 * Since 2008 - 2013
 */

package org.teacup.eightdays.dao;

import java.util.*;

import javacommon.base.*;
import javacommon.util.*;

import cn.org.rapid_framework.util.*;
import cn.org.rapid_framework.web.util.*;
import cn.org.rapid_framework.page.*;
import cn.org.rapid_framework.page.impl.*;

import org.teacup.eightdays.model.*;
import org.teacup.eightdays.dao.*;
import org.teacup.eightdays.service.*;
import org.teacup.eightdays.vo.query.*;

/**
 * @author Abner email:521yexu2008(a)163.com
 * @version 1.0
 * @since 1.0
 */

import static cn.org.rapid_framework.util.ObjectUtils.*;
import org.springframework.stereotype.Repository;

@Repository
public class ProductDao extends BaseHibernateDao<Product,java.lang.Long>{

	public Class getEntityClass() {
		return Product.class;
	}
	
	public Page findPage(ProductQuery query) {
        StringBuilder sqlBuilder = new StringBuilder("select t from Product t where 1=1 ");
        if(isNotEmpty(query.getProductId())) {
            sqlBuilder.append(" and  t.productId = :productId ");
        }
        if(isNotEmpty(query.getProductTypeId())) {
            sqlBuilder.append(" and  t.productTypeId = :productTypeId ");
        }
        if(isNotEmpty(query.getName())) {
            sqlBuilder.append(" and  t.name = :name ");
        }
        if(isNotEmpty(query.getCode())) {
            sqlBuilder.append(" and  t.code = :code ");
        }
        if(isNotEmpty(query.getProductDescribe())) {
            sqlBuilder.append(" and  t.productDescribe = :productDescribe ");
        }
        if(isNotEmpty(query.getProducingArea())) {
            sqlBuilder.append(" and  t.producingArea = :producingArea ");
        }
        if(isNotEmpty(query.getProductionCertificate())) {
            sqlBuilder.append(" and  t.productionCertificate = :productionCertificate ");
        }
        if(isNotEmpty(query.getProductStandardCode())) {
            sqlBuilder.append(" and  t.productStandardCode = :productStandardCode ");
        }
        if(isNotEmpty(query.getWorksInitials())) {
            sqlBuilder.append(" and  t.worksInitials = :worksInitials ");
        }
        if(isNotEmpty(query.getWorksAddress())) {
            sqlBuilder.append(" and  t.worksAddress = :worksAddress ");
        }
        if(isNotEmpty(query.getBurdenSheet())) {
            sqlBuilder.append(" and  t.burdenSheet = :burdenSheet ");
        }
        if(isNotEmpty(query.getStore())) {
            sqlBuilder.append(" and  t.store = :store ");
        }
        if(isNotEmpty(query.getQualityGuaranteePeriod())) {
            sqlBuilder.append(" and  t.qualityGuaranteePeriod = :qualityGuaranteePeriod ");
        }
        if(isNotEmpty(query.getAdditive())) {
            sqlBuilder.append(" and  t.additive = :additive ");
        }
        if(isNotEmpty(query.getPackaging())) {
            sqlBuilder.append(" and  t.packaging = :packaging ");
        }
        if(isNotEmpty(query.getBrand())) {
            sqlBuilder.append(" and  t.brand = :brand ");
        }
        if(isNotEmpty(query.getCatena())) {
            sqlBuilder.append(" and  t.catena = :catena ");
        }
        if(isNotEmpty(query.getStandard())) {
            sqlBuilder.append(" and  t.standard = :standard ");
        }
        if(isNotEmpty(query.getBarCode())) {
            sqlBuilder.append(" and  t.barCode = :barCode ");
        }
        if(isNotEmpty(query.getWeight())) {
            sqlBuilder.append(" and  t.weight = :weight ");
        }
        if(isNotEmpty(query.getType())) {
            sqlBuilder.append(" and  t.type = :type ");
        }
        if(isNotEmpty(query.getCost())) {
            sqlBuilder.append(" and  t.cost = :cost ");
        }
        if(isNotEmpty(query.getPrice())) {
            sqlBuilder.append(" and  t.price = :price ");
        }
        if(isNotEmpty(query.getStock())) {
            sqlBuilder.append(" and  t.stock = :stock ");
        }
        if(isNotEmpty(query.getStockTemp())) {
            sqlBuilder.append(" and  t.stockTemp = :stockTemp ");
        }
        if(isNotEmpty(query.getSalesVolume())) {
            sqlBuilder.append(" and  t.salesVolume = :salesVolume ");
        }
        if(isNotEmpty(query.getSalesVolumeSham())) {
            sqlBuilder.append(" and  t.salesVolumeSham = :salesVolumeSham ");
        }
        if(isNotEmpty(query.getOffShareTimeBegin())) {
            sqlBuilder.append(" and  t.offShareTime >= :offShareTimeBegin ");
        }
        if(isNotEmpty(query.getOffShareTimeEnd())) {
            sqlBuilder.append(" and  t.offShareTime <= :offShareTimeEnd ");
        }
        if(isNotEmpty(query.getOnShareTimeBegin())) {
            sqlBuilder.append(" and  t.onShareTime >= :onShareTimeBegin ");
        }
        if(isNotEmpty(query.getOnShareTimeEnd())) {
            sqlBuilder.append(" and  t.onShareTime <= :onShareTimeEnd ");
        }
        if(isNotEmpty(query.getStatus())) {
            sqlBuilder.append(" and  t.status = :status ");
        }
        if(isNotEmpty(query.getInsertUser())) {
            sqlBuilder.append(" and  t.insertUser = :insertUser ");
        }
        if(isNotEmpty(query.getInsertTimeBegin())) {
            sqlBuilder.append(" and  t.insertTime >= :insertTimeBegin ");
        }
        if(isNotEmpty(query.getInsertTimeEnd())) {
            sqlBuilder.append(" and  t.insertTime <= :insertTimeEnd ");
        }
        if(isNotEmpty(query.getUpdateUser())) {
            sqlBuilder.append(" and  t.updateUser = :updateUser ");
        }
        if(isNotEmpty(query.getUpdateTimeBegin())) {
            sqlBuilder.append(" and  t.updateTime >= :updateTimeBegin ");
        }
        if(isNotEmpty(query.getUpdateTimeEnd())) {
            sqlBuilder.append(" and  t.updateTime <= :updateTimeEnd ");
        }
        if(isNotEmpty(query.getSortColumns())) {
            sqlBuilder.append(" order by :sortColumns ");
        }	
        String sql = sqlBuilder.toString();
		return pageQuery(sql,query);
	}
	

}